package com.wxmp.wxapi.service.impl;

import com.wxmp.wxapi.service.IAccountService;
import com.wxmp.wxapi.service.PushService;
import com.wxmp.wxcms.domain.Account;
import com.wxmp.wxcms.domain.AccountFans;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Optional;

/**
 * @Description
 * @Author cys
 * @Date 2022/10/12 10:08 AM
 */
@Service("warmReminder")
public class WarmReminderPushServiceImpl implements PushService {

    @Resource
    private Map<String, IAccountService> accountServiceMap;

    @Override
    public void push(AccountFans accountFans, String templateId, Account account) {
        IAccountService accountService = Optional.ofNullable(accountServiceMap.get(account.getName())).orElse(accountServiceMap.get("default"));
        accountService.pushWarmReminderMessage(accountFans, templateId, account);
    }
}
